<% content_for :page_title do -%>
  <%= plural_resource_name(Mes::Workflow) -%>
<% end -%>

<% content_for :page_actions do -%>
  <%= button_link_to Mes.t(:new_workflow), new_object_url, class: 'btn-success', icon: 'plus' %>
<% end if policy(Mes::Workflow).create? -%>

<% if @workflows.any? -%>
  <table class="table">
    <thead>
      <tr data-hook="workflow_header">
        <th><%= Mes.t(:name) -%> / <%= Mes.t(:description) -%></th>
        <th><%= Mes.t(:workflow) -%></th>
        <th><%= Mes.t(:state) %></th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <% @workflows.each do |workflow| -%>
      <tr id="<%= modeler_dom_id workflow %>" data-hook="workflow_row">
        <td>
          <%= workflow.name -%><br>
          <%= workflow.description -%>
        </td>
        <td>
          <%= workflow.steps.map(&:name).join('->').truncate(80, separator: '->') -%><br>
          <%= workflow.steps.map(&:description).join('->').truncate(80, separator: '->') -%>
        </td>
        <td><%= Mes.t(workflow.active? ? :active : :inactive) -%></td>
        <td class="actions text-right">
          <%= link_to_edit(workflow, no_text: true) if policy(Mes::Workflow).edit? %>
          <%= link_to_delete(workflow, no_text: true) if policy(Mes::Workflow).destroy? %>
        </td>
      </tr>
      <% end -%>
    </tbody>
  </table>
<% else -%>
  <div class="alert alert-info no-objects-found">
    <%= Mes.t(:no_resource_found, resource: plural_resource_name(Mes::Workflow)) %>,
    <%= link_to(Mes.t(:add_one), new_object_url) if policy(Mes::Workflow).create? %>!
  </div>
<% end -%>
